<?php

namespace App\Admin\Controllers;

use App\Admin\Extensions\StatistcsMoonExcelExpoter;
use App\Models\WorkUser;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use App\Admin\Repositories\WorkUserStatisticsMoonApi;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;

class WorkUserStatisticsMoonController extends AdminController
{

    protected $title = '务工人员信息统计(月)';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid($repository = null)
    {
        $grid = new Grid(new WorkUserStatisticsMoonApi());
        $grid->disableCreateButton();

        $grid->filter(function (Grid\Filter $filter) {
            $filter->panel();
            $filter->expand();

            $filter->date('moon', '选择月份')->width(5);

        });
        $grid->disablePagination();
        $grid->export(new StatistcsMoonExcelExpoter());

        $grid->number('序号');
        $grid->column('engineering','项目名称');
        $grid->column('shangYue','上月人数');
        $grid->column('benYue','本月人数');
        $grid->column('xinJin','新进人数');
        $grid->column('liTui','本月离退人数');

        $grid->disableActions();
        $grid->actions(function (Grid\Displayers\Actions $actions) {
            $actions->disableDelete();
            $actions->disableEdit();
            $actions->disableQuickEdit();
            $actions->disableView();
        });


        return $grid;
    }

    protected function form()
    {
        $form = new Form(new InTheater());

        $form->display('id', 'ID');
        $form->text('title')->rules('required');
        $form->text('original_title');
        $form->textarea('summary');
        $form->url('alt');
        $form->url('mobile_url');
        $form->url('share_url');
        $form->tags('countries');
        $form->tags('genres');
        $form->tags('aka');
        $form->year('year');

        $form->disableViewButton();
        $form->disableViewCheck();

        return $form;
    }
}
